function test_CARE()
    data=D300F3();    
    [corrplanes,sups, corratts,corrpoints]=CARE(data,3,0.0006,0.25);
    r=200;
    if length(corrplanes) >= 1
        [x,y]=meshgrid(-r:2*r:r);
        z=(0.5*x-0.84*y+0.085666)/0.169;
        surf(x,y,z,'FaceColor','yellow','FaceAlpha',0.2);
        hold on;
        points=corrpoints{1};
        plot3(points(:,1)',points(:,2)',points(:,3)','black+');
        hold on;
    end
    
    corratts={};
    for i=1:length(corrplanes)
        corratts{i}=[1,2,3];
    end
    displaycorrelations(corrplanes,sups,corratts,0.01, 'test_CARE.txt');
end

function data=D300F3()
    numpoints = 100;
    r=200;
    x1=randint(1,numpoints,[-r,r]);
    y1=randint(1,numpoints,[-r,r]);
    z1=2*x1+y1+randn(1,numpoints); % 2x1+x2-x3=0
    x2=randint(1,numpoints,[-r,r]);
    y2=randint(1,numpoints,[-r,r]);
    z2=x2*3-y2*5+randn(1,numpoints); % 3x1-5x2-x3=0
    x3=randint(1,numpoints,[-r,r]);
    y3=randint(1,numpoints,[-r,r]);
    z3=-4*x3-2*y3+100+randn(1,numpoints); % 4x1+2x2+x3=100
    x=[x1,x2,x3];
    y=[y1,y2,y3];
    z=[z1,z2,z3];
    data=[ x',y',z'];
    plot3(x,y,z,'r.');
    hold on;
%     [x,y] = meshgrid(-r:2*r:r);
%     z=3*x-5*y;
%     surf(x,y,z,'FaceColor','cyan','FaceAlpha',0.2);
%     hold on;
%     z=2*x+y;
%     surf(x,y,z,'FaceColor','yellow','FaceAlpha',0.2);
%     hold on;
%     z=-4*x-2*y+100;
%     surf(x,y,z,'FaceColor','green','FaceAlpha',0.2);
%     hold on;
    grid on;
end
